//
//  AppListTabBarViewController.m
//  LimitFree
//
//  Created by LZXuan on 15-6-8.
//  Copyright (c) 2015年 轩哥. All rights reserved.
//

#import "AppListTabBarViewController.h"
#import "AppListViewController.h"
@interface AppListTabBarViewController ()

@end

@implementation AppListTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createViewControllers];
}
- (void)createViewControllers {
    //解析 plist
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Controllers" ofType:@"plist"];
    NSArray *arr = [NSArray arrayWithContentsOfFile:path];
    
    NSArray *urls = @[kLimitUrl,kReduce,kFreeUrl,kSubjectUrl,kHotUrl];
    NSArray *categorys = @[kLimitType,kReduceType,kFreeType,kSubjectType,kHotType];
    NSMutableArray *vcArr = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < arr.count; i++) {
        NSDictionary *dict = arr[i];
        //动态创建 类的对象
        Class cls = NSClassFromString(dict[@"className"]);
        AppListViewController *app = [[cls alloc] init];
        //创建导航
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:app];
        //设置导航和标签栏标题
        app.title = dict[@"title"];
        //设置标签栏标签图片
        nav.tabBarItem.image = [UIImage imageNamed:dict[@"iconName"]];
        //正向传值
        app.requestUrl = urls[i];
        app.category = categorys[i];
        //加入导航
        [vcArr addObject:nav];
    }
    self.viewControllers = vcArr;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end







